package Underworld_Survival;

import java.util.function.Consumer;

abstract class Food extends Item{
    private transient Consumer<Role> effect; // 关键：使用 Consumer 定义效果

    public Food(String itemName, String itemIntroduction, String itemEffect,
                  CurrencyType purchaseCurrency, int priceOfPurchaseItem,
                int priceOfSellingItem, Consumer<Role> effect){
        super(itemName,itemIntroduction,itemEffect,purchaseCurrency,priceOfPurchaseItem,priceOfSellingItem);
        this.effect=effect;
    }

    // 触发食物效果
    public void applyFoodEffect(Role role) {
        effect.accept(role);
    }

}

//全局食物

//1.夏日西瓜summerWatermelon
class summerWatermelon extends Food{
    public summerWatermelon(){
        super("[夏日西瓜]","清凉可口的西瓜，让人看了垂涎三尺",
                "恢复血量：15",CurrencyType.GOLD,30, 15,
                role->{role.refillHP(15);}
        );}

    @Override
    public String getItemId() { return "food_summerWatermelon"; }

}
//2.大肉largePieceOfMeat
class largePieceOfMeat extends Food{
    public largePieceOfMeat(){
        super("[大肉]","肉类食物，吃了能恢复血量和能量。",
                "恢复血量20  恢复能量10",CurrencyType.GOLD,50, 30,
                role->{
            if(role instanceof Player){
                    role.refillHP(20);((Player) role).refillAgi(10);}
            else{ role.refillHP(20);}
        });}

    @Override
    public String getItemId() { return "food_largePieceOfMeat"; }

}
//3.营养草nutritiousGrass
class nutritiousGrass extends Food{
    public nutritiousGrass(){
        super("[营养草]","不同寻常的药草，富含各种营养物质",
                "恢复血量50%  恢复能量50%",CurrencyType.GOLD,100, 50,
                role->{if(role instanceof Player){
                    role.refillHP((int)(role.getTotalMaxHP()*0.5));
                    ((Player) role).refillAgi((int)(((Player) role).getTotalMaxAgi()*0.5));
                }else{
                    role.refillHP((int)(role.getTotalMaxHP()*0.5));
                }}
       );
    }
    @Override
    public String getItemId() { return "food_nutritiousGrass"; }
}
//4.精华草essenceGrass
class essenceGrass extends Food{
    public essenceGrass(){
        super("[精华草]","一种神奇药草，吃了能疗愈全身",
                "恢复血量100%  恢复能量100%",CurrencyType.GOLD,170, 90,
                role->{if(role instanceof Player){
                    role.refillHP(role.getTotalMaxHP());
                    ((Player) role).refillAgi(((Player) role).getTotalMaxAgi());
                }else{
                    role.refillHP(role.getTotalMaxHP());
                }}
        );
    }

    @Override
    public String getItemId() { return "food_essenceGrass"; }

}
//5.毒蘑菇poisonousMushroom
class poisonousMushroom extends Food{
    public poisonousMushroom(){
        super("[毒蘑菇]","诡秘微光蘑菇，藏着高风险与高回报",
                "恢复血量：80  debuff：【中毒】",CurrencyType.GOLD,70, 30,
                role->{role.refillHP(80);role.addBuff(new poison());}
        );
    }

    @Override
    public String getItemId() { return "food_poisonousMushroom"; }

}
//6.烈酒strongLiquor
class strongLiquor extends Food{
    public strongLiquor(){
        super("[烈酒]","喝下-- 全身都要烧起来了！",
                "buff：【沸血】  debuff：【灼烧】",CurrencyType.GOLD,50, 30,
                role->{role.addBuff(new burning());role.addBuff(new boilingBlood());
                }
        );
    }

    @Override
    public String getItemId() { return "food_strongLiquor"; }

}

